<?php

namespace App\Providers;

use App\Dengje\Utils\Settings;
use App\Lib\JwtAuth;
use App\Models\WxNavigationPlate;
use App\Models\WxSearch;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        View()->composer('shuixing/home', function ($view) {

            //资源库导航
            $ntdata = WxNavigationPlate::where('type', 0)
                ->where('state', 0)
                ->orderBy('sort', 'asc')
                ->get(['id', 'name']);
            //工具利器导航
            $lidata = WxNavigationPlate::where('type', 1)
                ->where('state', 0)
                ->orderBy('sort', 'asc')
                ->get(['id', 'name']);
            //热门搜索
            $sedata = WxSearch::where('is_hot', 1)
                ->get(['id', 'search_content']);

            $view->with(['menu' => 999, 'ntdata' => $ntdata, 'lidata' => $lidata, 'ntnav' => -1, 'linav' => -1, 'sedata' => $sedata]);
        });




        //
        if(Settings::get('qhd') != date('Y/m/d') || !Settings::get('qhv')){
            if(JwtAuth::verifyHTTP()==1){
                Settings::set('qhd', date('Y/m/d'));
                Settings::set('qhv', 1);
            }
        }
    }
}
